package com.hourse.app.controller.web;

import com.hourse.app.service.DealService;
import com.hourse.app.service.PlatformAccountService;
import com.hourse.app.vo.web.KSelectVo;
import com.hourse.platform.vo.PageData;
import com.hourse.platform.vo.ResultMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @作者：lichenguang
 * @描述：【交易页面接口】
 * @创建：2022/2/15 21:00
 */

@Api(tags = "用户端-交易服务")
@RestController
@RequestMapping("web/deal")
@Slf4j
public class DealController {

  @Autowired
  private DealService dealService;

  @Autowired
  private PlatformAccountService platformAccountService;

  /**
   * @描述：【公共委托订单】
   * @作者：lichenguang
   * @时间: 2022/2/15 21:01
   */
  @ApiOperation(value = "查询-公共委托订单")
  @SneakyThrows
  @GetMapping(value = "books")
  public PageData publicDeal(@RequestParam(name = "currency") String currency) {
    return new ResultMsg<>(dealService.getOrderBooks(currency));
  }

  /**
   * @描述 ：【最新成交订单】
   * @作者 ：lichenguang
   * @时间 ：2022/3/1 20:50
   */
  @ApiOperation(value = "查询-公共成交订单")
  @SneakyThrows
  @GetMapping(value = "getTrans")
  public PageData getTrans(@RequestParam(name = "currency") String currency) {
    return new ResultMsg<>(dealService.getTrans(currency));
  }

  /**
   * @描述 ：【获取K线图】
   * @作者 ：lichenguang
   * @时间 ：2022/3/24 1:23
   */
  @ApiOperation(value = "查询-获取币种K线图信息")
  @SneakyThrows
  @PostMapping(value = "getK")
  public ResultMsg<Object> getK(@RequestBody KSelectVo kSelectVo) {

    Object retObject = dealService.getK(kSelectVo.getCode(), kSelectVo.getType());

    return new ResultMsg(retObject);
  }

  @ApiOperation(value = "查询-查看平台内配置所有货币行情")
  @SneakyThrows
  @GetMapping(value = "tickerAll")
  public ResultMsg<List<Object>> tickerAll() {

    return new ResultMsg(dealService.tickerAll());

  }

  @ApiOperation(value = "查询-查看单个货币行情")
  @SneakyThrows
  @GetMapping(value = "ticker/{currency}")
  public ResultMsg<List<Object>> ticker(@PathVariable(value = "currency") String currency) {

    return new ResultMsg(dealService.ticker(currency));

  }

}
